<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>3d的立方盒子</title>
    <style>
        body {
            perspective: 500px;
        }
        
        .box {
            position: relative;
            width: 200px;
            height: 200px;
            margin: 100px auto;
            transform-style: preserve-3d;
            /* transition: all 2s; */
            animation: hezi 2s linear infinite;
        }
        
        .box1 {
            position: relative;
            width: 100px;
            height: 100px;
            transform-style: preserve-3d;
            animation: xiaohezi 2s linear infinite;
        }
        
        .box1 span {
            position: absolute;
            top: 0px;
            left: 0px;
            width: 100px;
            height: 100px;
            text-align: center;
            font-size: 30px;
            color: silver;
            line-height: 100px;
        }
        
        @keyframes hezi {
            100% {
                transform: rotate3d(1, 1, 0, 360deg);
            }
        }
        
        .box div {
            position: absolute;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
            text-align: center;
            font-size: 30px;
            color: silver;
            line-height: 200px;
        }
        
        .box div:nth-child(1) {
            background-color: tomato;
            width: 100%;
            height: 100%;
            transform: translatez(100px) rotateY(0deg);
        }
        
        .box div:nth-child(2) {
            background-color: yellowgreen;
            width: 100%;
            height: 100%;
            transform: translatez(-100px) rotateY(180deg);
        }
        
        .box div:nth-child(3) {
            background-color: grey;
            width: 100%;
            height: 100%;
            transform: translatey(-100px) rotatex(90deg);
        }
        
        .box div:nth-child(4) {
            background-color: skyblue;
            width: 100%;
            height: 100%;
            transform: translatey(100px) rotatex(90deg);
        }
        
        .box div:nth-child(5) {
            background-color: purple;
            width: 100%;
            height: 100%;
            transform: translatex(-100px) rotateY(-90deg);
        }
        
        .box div:nth-child(6) {
            background-color: black;
            width: 100%;
            height: 100%;
            transform: translatex(100px) rotateY(90deg);
        }
        /* 小盒子的部分 */
        
        .box1 span:nth-child(1) {
            background-color: tomato;
            width: 100px;
            height: 100px;
            transform: translatex(50px) rotateY(0deg);
        }
        
        .box1 span:nth-child(2) {
            background-color: yellowgreen;
            width: 100px;
            height: 100px;
            transform: translatex(-50px) rotateY(180deg);
        }
        
        .box1 span:nth-child(3) {
            background-color: grey;
            width: 100px;
            height: 100px;
            transform: translatex(-50px) rotatex(90deg);
        }
        
        .box1 span:nth-child(4) {
            background-color: skyblue;
            width: 100px;
            height: 100px;
            transform: translatex(50px) rotatex(90deg);
        }
        
        .box1 span:nth-child(5) {
            background-color: purple;
            width: 100px;
            height: 100px;
            transform: translatex(-50px) rotateY(-90deg);
        }
        
        .box1 span:nth-child(6) {
            background-color: black;
            width: 100px;
            height: 100px;
            transform: translatex(50px) rotateY(90deg);
        }
    </style>
</head>

<body>
    <div class="box">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
    </div>
    <div class="box1">
        <span>1</span>
        <span>2</span>
        <span>3</span>
        <span>4</span>
        <span>5</span>
        <span>6</span>
    </div>
</body>

</html>